package yf.mall.controller.api;

import com.yf.annotation.LoginUserId;
import com.yf.response.R;
import com.yf.service.LogisticsService;
import com.yf.vo.LogResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yf.mall.entity.UserEntity;
import yf.mall.service.UserService;

@RequestMapping("/api/logistics")
@RestController
public class ApiLogisticsController {

    @Autowired
    private LogisticsService logisticsService;

    @Autowired
    private UserService userService;

    @GetMapping("/find")
    private R<LogResultVo> find(@LoginUserId Long userId, String no, String type){
        no = no.replaceAll(" ", "");
        LogResultVo resultVo = logisticsService.find(no,type);
        UserEntity userEntity = this.userService.get(userId);
        return R.ok(resultVo).putExtra("name",userEntity.getName());
    }

}
